<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>一类积案</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style>
        .layui-col-space15 > * {
            padding: 0;
        }
    </style>
</head>
<body>
<div class="layui-fluid attention-case" style="margin-top: 10px">
    <div class="layui-row layui-col-space15">
        <label for="swjgDm"></label>
        <input type="text" name="swjgDm" id="swjgDm" th:value="${swjgDm}" hidden>
        <div class="user_table_div">
            <div id="searchParam">
                <div class="layui-form-item">
                    <div class="layui-input-inline">
                        <label for="nsrmc"></label>
                        <input type="text" id="nsrmc" class="layui-input" autocomplete="off"
                               placeholder="请输入企业名称">
                    </div>
                    <div class="layui-input-inline">
                        <label for="nsrsbh"></label>
                        <input type="text" id="nsrsbh" class="layui-input" autocomplete="off"
                               placeholder="请输纳税人识别号">
                    </div>
                    <div class="layui-input-inline">
                        <label for="ajbh"></label>
                        <input type="text" id="ajbh" class="layui-input" autocomplete="off" placeholder="请输案件编号">
                    </div>
                    <div class="layui-input-inline layui-form">
                        <label for="ajzt"></label>
                        <select id="ajzt">
                            <option value="0">请选择案件状态</option>
                            <option value="2" th:selected="${ajztDm}==2">检查</option>
                            <option value="3" th:selected="${ajztDm}==3">审理</option>
                            <option value="4" th:selected="${ajztDm}==4">执行</option>
                            <option value="901" th:selected="${ajztDm}==901">办结</option>
                            <option value="5" th:selected="${ajztDm}==5">结案</option>
                        </select>
                    </div>
                    <div class="layui-input-inline layui-form">
                        <label for="jcks"></label>
                        <select id="jcks"></select>
                    </div>
                    <div class="layui-input-inline ">
                        <button class="layui-btn" onclick="searchAjxx()" id="search">查询</button>
                    </div>
                </div>

            </div>
            <table class="layui-hide" id="ajxx_table" lay-filter="ajxx_table"></table>
        </div>
    </div>
</div>
<div class="ajxx_record_div" hidden>
    <table class="layui-hide" id="flowRecord_table" lay-filter="flowRecord_table"></table>
</div>

<div class="log_record_div" hidden>
    <table class="layui-hide" id="logRecord_table" lay-filter="logRecord_table"></table>
</div>
</body>

<script type="text/html" id="ajxxtool">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="ajxxRecord">流转记录</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="logRecord">日志记录</a>
</script>

<script type="text/html" id="toolbar_log">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-primary" lay-event="returnBack">返回</button>
    </div>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script language="JavaScript" src="/newmain/js/bizjs/gy.js"></script>
<script th:inline="none">
    var pub_caseId;
    var tableIns1;
    //获取token
    var token = CoreUtil.getData("access_token");
    //地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    let $ = jQuery = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var util = layui.util;
    var tree = layui.tree;

    layui.use(['layer', 'form', 'table', 'util', 'tree'], function () {

        //加载table
        tableIns1 = table.render({
            elem: '#ajxx_table',
            contentType: 'application/json',
            headers: {"authorization": token},
            page: true,
            where: {
                caseId: '4A83C7C7819843A6BC439E31E864FDDB',
                ajztDm: $("#ajzt").val(),
                swjgDm: $("#swjgDm").val()
            },
            url: '/attention/backlogCaseManagement/listFirstajxx',
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
                }
            },
            cols: [
                [
                    {field: 'jcajxxuuid', title: '金三案件信息表主键', width: 0, hide: true},
                    {field: 'ajbh', title: '案件编号', width: 180, align: 'center'},
                    {field: 'nsrsbh', title: '纳税人识别号', width: 200, align: 'center'},
                    {field: 'nsrmc', title: '纳税人名称', width: 280, align: 'center'},
                    {field: 'ajjcztDm', title: '金三状态', width: 120, align: 'center'},
                    {field: 'ajjcztDm', title: '实际状态', width: 120, align: 'center'},
                    {field: 'jcks', title: '检查科室', width: 120, align: 'center'},
                    {field: 'jcr', title: '检查人', width: 260, align: 'center'},
                    {field: 'slry', title: '审理员', width: 260, align: 'center'},
                    {field: 'zxry', title: '执行人', width: 260, align: 'center'},
                    {
                        field: 'larq', title: '立案日期', width: 140, align: "center", templet: function (d) {
                            if (!d.larq) {
                                return '';
                            }
                            return layui.util.toDateString(d.larq, 'yyyy-MM-dd');
                        }
                    },
                    {
                        field: 'createTime', title: '案件导入日期', width: 140, align: "center", templet: function (d) {
                            if (!d.createTime) {
                                return '';
                            }
                            return layui.util.toDateString(d.createTime, 'yyyy-MM-dd');
                        }
                    },
                    {toolbar: '#ajxxtool', title: '操作', width: 180, align: 'center'}
                ]
            ],
            toolbar: '#toolbar'
        });


        table.on('tool(ajxx_table)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'ajxxRecord':
                    //加载flowrecord
                    table.render({
                        elem: '#flowRecord_table'
                        , contentType: 'application/json'
                        , headers: {"authorization": token}
                        , where: {relevance: data.jcajxxuuid}
                        , url: '/attention/attentionCase/flowRecord' //数据接口
                        , method: 'POST'
                        , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                            return {
                                "code": res.code, //解析接口状态
                                "msg": res.msg, //解析提示文本
                                "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                                "data": CoreUtil.isEmpty(res.data) ? null : res.data //解析数据列表
                            }
                        }
                        , cols: [
                            [
                                {field: 'category', title: '类型', width: 250, align: 'center'},
                                {field: 'date', title: '日期', width: 120, align: 'center'},
                                {field: 'czr', title: '操作人', width: 140, align: 'center'},
                                {field: 'ajbh', title: '案件编号', width: 200, align: 'center'},
                                {field: 'nsrmc', title: '企业名称', width: 250, align: 'center'},
                                {field: 'czsj', title: '操作时间', width: 120, align: 'center'},
                                {field: 'bz', title: '内容', width: 250, align: 'center'},

                            ]
                        ]
                        , toolbar: '#toolbar_log'
                    });
                    $(".ajxx_record_div").show();
                    $(".layui-fluid").hide();
                    break;
                case 'logRecord':
                    //日志记录
                    skipOpen("/index/statistics/ajlogrecord?relevance=" + data.jcajxxuuid, "11001", "日志记录");
                    // table.render({
                    //     elem: '#logRecord_table'
                    //     , contentType: 'application/json'
                    //     , headers: {"authorization": token}
                    //     , where: {relevance:data.jcajxxuuid}
                    //     , url: '/attention/attentionCase/logRecord' //数据接口
                    //     , method: 'POST'
                    //     , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                    //         return {
                    //             "code": res.code, //解析接口状态
                    //             "msg": res.msg, //解析提示文本
                    //             "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    //             "data": CoreUtil.isEmpty(res.data) ? null : res.data //解析数据列表
                    //         }
                    //     }
                    //     , cols: [
                    //         [
                    //             {field: 'ajbh', title: '案件编号', width: 200,align : 'center'},
                    //             {field: 'ajmc', title: '案件名称', width: 200,align : 'center'},
                    //             {field: 'nsrsbh', title: '纳税人识别号', width: 200,align : 'center'},
                    //             {field: 'nsrmc', title: '企业名称', width: 250,align : 'center'},
                    //             {field: 'wcgz', title: '完成工作', width: 200,align : 'center'},
                    //             {field: 'fxwt', title: '发现问题', width: 250,align : 'center'},
                    //             {field: 'xbds', title: '下步打算', width: 250,align : 'center'},
                    //             {field: 'cjsj', title: '操作时间', width: 250,align : 'center'}
                    //         ]
                    //     ]
                    //     , toolbar: '#toolbar_log'
                    // });
                    // $(".log_record_div").show();
                    // $(".layui-fluid").hide();
                    break;
            }
        });

        table.on('toolbar(flowRecord_table)', function (obj) {
            $(".ajxx_record_div").hide();
            $(".layui-fluid").show();
        });


        table.on('toolbar(logRecord_table)', function (obj) {
            $(".log_record_div").hide();
            $(".layui-fluid").show();
        });

        //初始化检查科室查询条件
        CoreUtil.sendPost("/attention/gy/getcurrentswjgjcks", null, function (res) {
            let datas = res.data;
            let options = "<option value = '00'>请选择检查科室</option>";
            for (let i = 0; i < datas.length; i++) {
                options += '<option value="' + datas[i].swjgDm + '">' + datas[i].swjgjc + '</option>';
            }
            $('#jcks').append(options);
            // 更新select渲染
            form.render('select');
        });
    });

    function searchAjxx() {
        tableIns1.reload({
            where: { //设定异步数据接口的额外参数，任意设
                caseId: pub_caseId,
                nsrmc: $("#nsrmc").val(),
                nsrsbh: $("#nsrsbh").val(),
                ajbh: $("#ajbh").val(),
                jcks: $("#jcks").val(),
                ajztDm: $("#ajzt").val()
            }
            , page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }
</script>
</html>